const express = require('express');
const app = express();
const ejs = require('ejs');
const bodyParser = require('body-parser');
const session = require('express-session');
const mongoStore = require('connect-mongo');
const admin = require('./routers/admin.js');
app.engine('html',ejs.__express)
app.set('view engine','html')

app.use(session({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: true,
    cookie: { 
        maxAge:1000*60*60
    },
    store:mongoStore.create({
        mongoUrl:'mongodb://localhost:27017/userinfo',
        touchAfter:24*3600

    })
  }))
app.use(express.static('static'));
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use('/admin',admin)

app.listen(3000,()=>{
    console.log('服务器运行在3000端口')
})